package org.dbstar.scheduler.beans;

import java.io.Serializable;

/**
 * Catalog实体bean
 * 
 * @author 代波
 * @since 1.0.0
 * @version 1.0.0
 * @date 2012-4-21
 */
public class Catalog implements Serializable, Cloneable, Comparable<Catalog> {
	private static final long serialVersionUID = -558901412282740348L;

	private int id; // 目录编号
	private String name;// 目录名称
	private Integer parent;// 父目录编号
	private String description;// 目录内容描述
	private long createTime = System.currentTimeMillis();// 创建时间
	private Long modifyTime;// 最后修改时间
	private String owner;// 所有者，默认为创建人
	private String modifier;// 最后修改人

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Integer getParent() {
		return parent;
	}

	public void setParent(Integer parent) {
		this.parent = parent;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String desc) {
		this.description = desc;
	}

	public long getCreateTime() {
		return createTime;
	}

	public void setCreateTime(long createTime) {
		this.createTime = createTime;
	}

	public Long getModifyTime() {
		return modifyTime;
	}

	public void setModifyTime(Long modifyTime) {
		this.modifyTime = modifyTime;
	}

	public String getOwner() {
		return owner;
	}

	public void setOwner(String owner) {
		this.owner = owner;
	}

	public String getModifier() {
		return modifier;
	}

	public void setModifier(String modifier) {
		this.modifier = modifier;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + (int) (createTime ^ (createTime >>> 32));
		result = prime * result + id;
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Catalog other = (Catalog) obj;
		if (createTime != other.createTime)
			return false;
		if (id != other.id)
			return false;
		return true;
	}

	@Override
	public Catalog clone() throws CloneNotSupportedException {
		return (Catalog) super.clone();
	}

	@Override
	public int compareTo(Catalog o) {
		if (parent == null && o.parent != null) {
			return -1;
		} else if (parent != null && o.parent == null) {
			return 1;
		} else if (parent != null && o.parent != null) {
			if (parent < o.parent) {
				return -1;
			} else if (parent > o.parent) {
				return 1;
			}
		}

		if (id < o.id) {
			return -1;
		} else if (id > o.id) {
			return 1;
		}

		return 0;
	}
}
